﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NCT.MRS.DataAccessLayer.Entities;

namespace NCT.MRS.DataAccessLayer.Configurations
{
    public class TestRequestConfiguration : EntityTypeConfiguration<TestRequest>
    {
        public TestRequestConfiguration()
        {
            HasKey(P => P.Id);

            Property(P => P.PackageDiscount).IsRequired();
            Property(P => P.SubTotal).IsRequired();
            Property(P => P.Total).IsRequired();
            HasRequired(p => p.Client).WithMany(P => P.TestRequests).HasForeignKey(P => P.ClientId);
            HasRequired(P => P.ModifiedByUser).WithMany().HasForeignKey(P => P.ModifiedByUserId).WillCascadeOnDelete(false);
            HasMany(P => P.TestTypesResults).WithRequired(P => P.TestRequest).HasForeignKey(P => P.TestRequestId);
        }
    }
}
